var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { defineComponent, ref, computed, onMounted, h, watch, nextTick, onBeforeUnmount, resolveComponent, createElementBlock, openBlock, createElementVNode, createCommentVNode, withModifiers, toDisplayString, normalizeStyle, createVNode, withDirectives, Fragment, renderList, createBlock, vShow, resolveDirective, normalizeClass, withCtx, reactive, unref, createTextVNode, onUpdated, withKeys } from "vue";
import { ElIcon, ElSelect, ElOption, ElInput, ElMessage, ElMessageBox, ElLoading } from "element-plus";
import { CircleClose, CircleCheck, Plus, Minus, Search, CirclePlus, SwitchButton, Warning, Edit, Delete, MoreFilled, Close, Download } from "@element-plus/icons-vue";
import { defineStore } from "pinia";
import { v4 } from "uuid";
import moment from "moment";
import _ from "lodash";
import Split from "split.js";
const _sfc_main$5$1 = defineComponent({
  name: "NodeValue",
  props: {
    data: {
      type: Object,
      required: true
    },
    readonly: {
      type: Boolean,
      required: true
    }
  },
  setup(props, context) {
    const isHasFocus = ref(false);
    const validText = ref("");
    const checkText = ref("");
    const validTypeArr = ["Integer", "BitString", "NumericString", "Ia5string", "OctetString", "String"];
    const otherProps = computed(() => {
      return props.data.bitArray ? props.data.bitArray.map((x) => x ? 1 : 0).join("") : "";
    });
    const formValid = (data) => {
      if (data.isRequired && data.value === "") {
        validText.value = "字段必填";
        return;
      }
      if (data.controlType === "Integer") {
        const { minInclusive, maxInclusive, value } = data;
        if (!minInclusive && !maxInclusive) {
          checkText.value = validText.value = "";
          return;
        }
        if (Number(value) < minInclusive) {
          validText.value = `最小值为${minInclusive}`;
          return;
        }
        if (Number(value) > maxInclusive) {
          validText.value = `最大值为${maxInclusive}`;
          return;
        }
      } else if (data.controlType === "BitString") {
        const { Length } = data;
        checkText.value = `长度为${Length}的二进制数`;
        if (otherProps.value.length !== Length) {
          validText.value = `长度应为${Length}`;
          return;
        }
      }
      validText.value = "";
    };
    const updateEmit = () => {
      if (validText.value === "") {
        context.emit("updateForm", props.data);
      }
    };
    const publicEvent = {
      onfocus: () => {
        isHasFocus.value = true;
      },
      onblur: () => {
        isHasFocus.value = false;
      }
    };
    onMounted(() => {
    });
    const strategy = {
      Integer: (data) => {
        const { value, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          disabled,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: (val) => {
            if (!value) return;
            data.value = parseFloat(val);
            updateEmit();
          },
          ...publicEvent
        });
      },
      Ia5string: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: () => {
            updateEmit();
          },
          ...publicEvent
        });
      },
      String: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: () => {
            updateEmit();
          },
          ...publicEvent
        });
      },
      OctetString: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          attrs: { minlength: minLength, readonly: props.readonly },
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: (val) => {
            const is16Hex = /^[\-A-Fa-f0-9\s]*$/.test(val);
            if (is16Hex) {
              const newValue = value !== "" ? String(value).replace(/\s+/g, "").match(new RegExp("[^\\n]{1,2}", "g")).join(" ") : "";
              data.value = newValue;
              formValid(data);
              updateEmit();
            }
          }
        });
      },
      // NumericString: (data: nodeItem) => {
      //   const { Value: value, MinLength, IsReadOnly: disabled } = data;
      //   return h("el-input", {
      //     class: "int-input",
      //     props: { value, disabled },
      //     attrs: { minlength: MinLength, readonly: props.readonly },
      //     on: {
      //       input: (value: string) => {
      //         const isNumber = /^[\.\-0-9]*$/.test(value);
      //         if (isNumber) {
      //           data.Value = value;
      //           formValid(data);
      //         }
      //       },
      //       ...publicEvent,
      //     },
      //   });
      // },
      // BitString: (data: nodeItem) => {
      //   const { IsReadOnly: disabled } = data;
      //   const { value } = otherProps;
      //   return h("el-input", {
      //     class: "int-input",
      //     props: { otherProps.value.value, disabled },
      //     attrs: { readonly: props.readonly },
      //     on: {
      //       input: (value: string) => {
      //         const isBinary = /^[0|1]*$/.test(value);
      //         if (isBinary) {
      //           data.OtherProps = value;
      //           formValid(data);
      //         }
      //       },
      //       change: (value: string) => {
      //         data.BitArray = value.split("").map(x => !!Number(x));
      //       },
      //       ...publicEvent,
      //     },
      //   });
      // },
      Enum: (data) => {
        const { value, constraint, isReadOnly: disabled } = data;
        const options = [];
        constraint == null ? void 0 : constraint.forEach((optionValue) => {
          options.push({ label: optionValue, value: optionValue });
        });
        return h(
          ElSelect,
          {
            class: "custom-el-select",
            // 添加自定义类名
            modelValue: data.value,
            "onUpdate:modelValue": (val) => {
              data.value = val;
            },
            onChange: () => {
              updateEmit();
            },
            size: "small"
          },
          [
            ...options.map(
              (option) => h(ElOption, {
                key: option.value,
                label: option.label,
                value: option.value
              })
            )
          ]
        );
      },
      // Choice: (data: nodeItem) => {
      //   const { Value: value, Constraint, IsReadOnly: disabled } = data;
      //   const optionsArr = Constraint.map(value => {
      //     if (typeof value === "string") return;
      //     return h("el-option", { props: { label: value.Name, value } });
      //   });
      //   return h(
      //     "el-select",
      //     {
      //       class: "enum-select",
      //       props: { value, valueKey: "Name", placeholder: " ", disabled: disabled || props.readonly },
      //       on: {
      //         input: (value: string) => {
      //           data.Value = value;
      //         },
      //       },
      //     },
      //     [optionsArr],
      //   );
      // },
      Boolean: (data) => {
        const options = [
          { label: "是", value: true },
          { label: "否", value: false }
        ];
        return h(
          ElSelect,
          {
            class: "custom-el-select",
            // 添加自定义类名
            modelValue: data.value,
            "onUpdate:modelValue": (val) => {
              data.value = val;
            },
            onChange: () => {
              updateEmit();
            },
            size: "small"
          },
          [
            ...options.map(
              (option) => h(ElOption, {
                label: option.label,
                value: option.value
              })
            )
          ]
        );
      },
      Sequence: () => {
        return h("div", {}, "");
      },
      SequenceList: (data) => {
        const max = 9999;
        const min = 0;
        const len = data.child && data.child.length;
        const elementName = "成员";
        return h("div", { class: "sequence-list-value" }, [
          h(
            "div",
            {
              class: "btn-icon"
            },
            [
              h(
                ElIcon,
                {
                  class: `el-icon-plus ${len < max ? "" : "gray"}`,
                  onClick: () => {
                    if (len < max) {
                      const addRow = data.elementForm;
                      const count = data.child ? data.child.length + 1 : 1;
                      if (addRow) {
                        addRow.name = `${elementName}(${count})`;
                      }
                      data.child.push(JSON.parse(JSON.stringify(addRow)));
                      updateEmit();
                    }
                  }
                },
                [h(Plus)]
              ),
              h(
                ElIcon,
                {
                  class: `el-icon-minus ${len > min ? "" : "gray"}`,
                  onClick: () => {
                    if (len > min) {
                      data.child.pop();
                      updateEmit();
                    }
                  }
                },
                [h(Minus)]
              )
            ]
          )
          // h("span", { class: "valid-text" }, validText),
        ]);
      },
      // 其他控件类型的渲染逻辑...
      default: (data) => {
        return h("div", {}, `未定义的控件类型: ${data.controlType}`);
      }
    };
    formValid(props.data);
    return () => {
      return h(
        "div",
        {
          class: {
            "node-value": true,
            "node-valid-error": validText.value
          }
        },
        [
          (strategy[props.data.controlType] || strategy.default)(props.data),
          validTypeArr.includes(props.data.controlType) && h("span", { class: "valid-icon" }, [
            [
              validText.value ? h(ElIcon, { color: "red", size: 16 }, [h(CircleClose)]) : isHasFocus.value && !props.readonly && h(ElIcon, { color: "#67c23a", size: 16 }, [h(CircleCheck)])
            ],
            isHasFocus.value && validText.value && h("div", { class: "valid-tips err" }, validText.value),
            !validText.value && !props.readonly && isHasFocus.value && checkText.value && h("div", { class: "valid-tips" }, checkText.value)
          ])
        ]
      );
    };
  }
});
const _export_sfc$1 = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const NodeValue = /* @__PURE__ */ _export_sfc$1(_sfc_main$5$1, [["__scopeId", "data-v-a8b820df"]]);
const systolicIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<g id="HTSCIT_&#229;&#177;&#149;&#229;&#188;&#128; 2">\r\n<path id="Vector" d="M6.27673 6.28553H17.7233V17.7409H6.27673V6.28553ZM5 5.00881V19H19V5H5V5.00881Z" fill="currentColor"/>\r\n<path id="Vector_2" d="M8 13V11H16V13H8Z" fill="#3a6ef6"/>\r\n</g>\r\n</svg>\r\n';
const expandIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<g id="HTSCIT_&#229;&#177;&#149;&#229;&#188;&#128; 1">\r\n<path id="Vector" d="M6.27673 6.28553H17.7233V17.7409H6.27673V6.28553ZM5 5.00881V19H19V5H5V5.00881Z" fill="currentColor"/>\r\n<path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M12.5471 8.1925H11.4528V11.4642H8.18115V12.5585H11.4528V15.8302H12.5471V12.5585H15.8189V11.4642H12.5471V8.1925Z" fill="#3a6ef6"/>\r\n</g>\r\n</svg>\r\n';
const toolIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<path d="M13.9498 6C14.8591 6 15.699 6.29966 16.3746 6.80641L15.1183 8.06172L13.892 9.28926L14.7099 10.1078L17.1925 7.62438C17.7138 8.32091 17.997 9.16685 18 10.0369C18.003 10.9069 17.7257 11.7548 17.2093 12.4549C16.6928 13.1551 15.9646 13.6702 15.1325 13.9241C14.3004 14.178 13.4087 14.1571 12.5894 13.8645L8.98345 17.4702C8.82338 17.6359 8.6319 17.7682 8.42019 17.8591C8.20848 17.9501 7.98077 17.9979 7.75036 17.9999C7.51995 18.0019 7.29145 17.958 7.07819 17.8708C6.86493 17.7835 6.67118 17.6546 6.50825 17.4917C6.34532 17.3288 6.21647 17.135 6.12922 16.9217C6.04197 16.7084 5.99806 16.4799 6.00007 16.2495C6.00207 16.019 6.04994 15.7913 6.14088 15.5796C6.23183 15.3678 6.36402 15.1763 6.52976 15.0163L10.1351 11.41C9.9171 10.7988 9.84914 10.1442 9.93696 9.5013C10.0248 8.85838 10.2658 8.24598 10.6397 7.71569C11.0137 7.1854 11.5095 6.75274 12.0856 6.45416C12.6616 6.15558 13.301 5.99982 13.9498 6Z" fill="currentColor"/>\r\n</svg>\r\n';
const _sfc_main$4$1 = defineComponent({
  name: "NodeItem",
  components: {
    NodeValue
  },
  props: {
    data: {
      type: Object,
      required: true
    },
    w: {
      type: Number,
      required: true
    },
    readonly: {
      type: Boolean,
      required: true
    }
  },
  setup(props, { emit }) {
    const isExpand = ref(props.data.isExpand !== false);
    const isChildren = computed(() => {
      return props.data.child && props.data.child.length > 0;
    });
    const handleUpdate = (data) => {
      emit("updateForm", data);
    };
    return {
      isExpand,
      isChildren,
      handleUpdate,
      systolicIcon,
      expandIcon,
      toolIcon
    };
  }
});
const _hoisted_1$2$1 = { class: "node-view" };
const _hoisted_2$2$1 = { class: "node-item" };
const _hoisted_3$1$1 = { class: "left-item" };
const _hoisted_4$5 = { class: "icon-view" };
const _hoisted_5$5 = ["innerHTML"];
const _hoisted_6$4 = ["innerHTML"];
const _hoisted_7$3 = { class: "label-view" };
const _hoisted_8$3 = {
  key: 0,
  class: "node-children"
};
const _hoisted_9$3 = {
  key: 1,
  class: "node-children"
};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_NodeValue = resolveComponent("NodeValue");
  const _component_NodeItem = resolveComponent("NodeItem", true);
  return openBlock(), createElementBlock("div", _hoisted_1$2$1, [
    createElementVNode("div", _hoisted_2$2$1, [
      createElementVNode("div", _hoisted_3$1$1, [
        createElementVNode("div", _hoisted_4$5, [
          _ctx.isChildren ? (openBlock(), createElementBlock("span", {
            key: 0,
            class: "ex-icon force-svg-16",
            innerHTML: _ctx.isExpand ? _ctx.systolicIcon : _ctx.expandIcon,
            onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.isExpand = !_ctx.isExpand, ["stop"]))
          }, null, 8, _hoisted_5$5)) : (openBlock(), createElementBlock("span", {
            key: 1,
            class: "icon",
            innerHTML: _ctx.toolIcon
          }, null, 8, _hoisted_6$4))
        ]),
        createElementVNode("div", _hoisted_7$3, toDisplayString(_ctx.data.name), 1)
      ]),
      createElementVNode("div", {
        class: "right-item",
        style: normalizeStyle({ width: _ctx.w ? `${_ctx.w / 2}px` : "" })
      }, [
        createVNode(_component_NodeValue, {
          data: _ctx.data,
          readonly: _ctx.readonly,
          onUpdateForm: _ctx.handleUpdate
        }, null, 8, ["data", "readonly", "onUpdateForm"])
      ], 4)
    ]),
    _ctx.isChildren ? (openBlock(), createElementBlock("div", _hoisted_8$3, [
      withDirectives(createElementVNode("div", null, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.child, (x, i) => {
          return openBlock(), createBlock(_component_NodeItem, {
            key: i,
            data: x,
            w: _ctx.w,
            readonly: _ctx.readonly,
            onUpdateForm: _ctx.handleUpdate
          }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
        }), 128))
      ], 512), [
        [vShow, _ctx.isExpand]
      ])
    ])) : createCommentVNode("", true),
    _ctx.data.controlType === "Choice" && _ctx.data.value ? (openBlock(), createElementBlock("div", _hoisted_9$3, [
      (openBlock(true), createElementBlock(Fragment, null, renderList([_ctx.data.value], (x, i) => {
        return openBlock(), createBlock(_component_NodeItem, {
          key: i,
          data: x,
          w: _ctx.w,
          readonly: _ctx.readonly,
          onUpdateForm: _ctx.handleUpdate
        }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
      }), 128))
    ])) : createCommentVNode("", true)
  ]);
}
const NodeItem = /* @__PURE__ */ _export_sfc$1(_sfc_main$4$1, [["render", _sfc_render$1], ["__scopeId", "data-v-49690e0a"]]);
const _sfc_main$3$1 = defineComponent({
  name: "NodeTree",
  components: {
    NodeItem
  },
  props: {
    data: {
      type: Array,
      required: true
    },
    isHideHeader: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    isLoading: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const treeTbodyW = ref(0);
    const treeTbody = ref(null);
    const scrollbar = ref(null);
    watch(
      () => props.data.length,
      () => {
        nextTick(() => {
          updateTreeTbodyWidth();
        });
      }
    );
    const updateTreeTbodyWidth = () => {
      if (treeTbody.value) {
        treeTbodyW.value = treeTbody.value.offsetWidth;
      }
    };
    const handleResize = () => {
      updateTreeTbodyWidth();
    };
    onMounted(() => {
      window.addEventListener("resize", handleResize);
    });
    onBeforeUnmount(() => {
      window.removeEventListener("resize", handleResize);
    });
    const handleUpdate = (data) => {
      emit("updateForm", data);
    };
    return {
      treeTbodyW,
      treeTbody,
      scrollbar,
      handleUpdate
    };
  }
});
const _hoisted_1$1$1 = { class: "node-content" };
const _hoisted_2$1$1 = { class: "tree-thead" };
const _hoisted_3$5 = {
  ref: "treeTbody",
  class: "tree-tbody"
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_NodeItem = resolveComponent("NodeItem");
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
  const _component_Empty = resolveComponent("Empty");
  const _directive_loading = resolveDirective("loading");
  return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$1$1, [
    withDirectives(createElementVNode("div", _hoisted_2$1$1, [
      _cache[0] || (_cache[0] = createElementVNode("div", { class: "item" }, "名称", -1)),
      createElementVNode("div", {
        class: "item",
        style: normalizeStyle({ width: _ctx.treeTbodyW ? `${_ctx.treeTbodyW / 2}px` : "" })
      }, "值", 4)
    ], 512), [
      [vShow, !_ctx.isHideHeader && _ctx.data.length]
    ]),
    withDirectives(createVNode(_component_el_scrollbar, {
      ref: "scrollbar",
      class: normalizeClass(["tree-scrollbar", _ctx.data.length ? "" : "fill-scroll"])
    }, {
      default: withCtx(() => [
        createElementVNode("div", _hoisted_3$5, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (x, i) => {
            return openBlock(), createBlock(_component_NodeItem, {
              key: i,
              data: x,
              w: _ctx.treeTbodyW,
              readonly: _ctx.readonly,
              onUpdateForm: _ctx.handleUpdate
            }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
          }), 128))
        ], 512)
      ]),
      _: 1
    }, 8, ["class"]), [
      [vShow, _ctx.data.length]
    ]),
    withDirectives(createVNode(_component_Empty, { class: "null-box" }, null, 512), [
      [vShow, !_ctx.data.length && !_ctx.isLoading]
    ])
  ])), [
    [_directive_loading, _ctx.isLoading]
  ]);
}
const index = /* @__PURE__ */ _export_sfc$1(_sfc_main$3$1, [["render", _sfc_render$2], ["__scopeId", "data-v-c3f35861"]]);
const SEND_DEVICE_CMD_KEY = "send-device-cmd";
const GET_DEVICE_DATA_KEY = "get-device-data";
const useDeviceStore = defineStore("deviceInjection", () => {
  const sendDeviceCmd = ref(null);
  const setInjections = (injections) => {
    if (injections.sendDeviceCmd) {
      sendDeviceCmd.value = injections.sendDeviceCmd;
    }
  };
  return { sendDeviceCmd, setInjections };
});
const useDeviceViewStore = defineStore("deviceViewStore", () => {
  const currentCommandList = ref([]);
  const storeCommandList = (commands) => {
    currentCommandList.value = commands;
  };
  const currentDevice = ref();
  const setCurrentDevice = (device) => {
    currentDevice.value = device;
  };
  const allDevices = ref([]);
  const setAllDevices = (devices) => {
    allDevices.value = devices;
  };
  const clickedDevice = ref([]);
  const setClickedDevice = (device) => {
    if (clickedDevice.value.findIndex((x) => x.id === device.id) === -1) {
      clickedDevice.value.push(device);
    }
  };
  const removeClickedDevice = (device) => {
    const index2 = clickedDevice.value.findIndex((x) => x.id === device.id);
    if (index2 !== -1) {
      clickedDevice.value.splice(index2, 1);
    }
  };
  const closedDevice = ref();
  const setClosedDevice = (device) => {
    closedDevice.value = device;
  };
  const openCloseMethodName = ref([]);
  const setOpenCloseMethodName = (methodName) => {
    var _a;
    if (!((_a = openCloseMethodName.value) == null ? void 0 : _a.includes(methodName))) {
      openCloseMethodName.value.push(methodName);
    }
  };
  const currentDeviceConnStatus = ref();
  const setCurrentDeviceConnStatus = (deviceWithStatus) => {
    currentDeviceConnStatus.value = deviceWithStatus;
  };
  return {
    currentCommandList,
    storeCommandList,
    currentDevice,
    setCurrentDevice,
    allDevices,
    setAllDevices,
    clickedDevice,
    setClickedDevice,
    removeClickedDevice,
    closedDevice,
    setClosedDevice,
    openCloseMethodName,
    setOpenCloseMethodName,
    currentDeviceConnStatus,
    setCurrentDeviceConnStatus
  };
});
function createCommand(moduleId2, fixedParams) {
  return async function(data, params, config2 = {}) {
    const calibStore = useDeviceStore();
    const sendDeviceCmd = calibStore.sendDeviceCmd;
    if (!sendDeviceCmd) {
      throw new Error("sendDeviceCmd 未在 Pinia 中初始化，请检查插件根组件是否正常挂载");
    }
    const commandPayload = {
      moduleId: moduleId2,
      fixedParams,
      data,
      params: { ...fixedParams, ...params },
      config: config2
    };
    const result = await sendDeviceCmd("execute", commandPayload);
    return result;
  };
}
const moduleId = "DeviceForm";
const sendCommand = createCommand(moduleId);
const downloadFileCommand = createCommand(moduleId);
const _hoisted_1$6 = { class: "device" };
const _hoisted_2$5 = { class: "element" };
const _hoisted_3$4 = { class: "element" };
const _hoisted_4$4 = {
  key: 0,
  class: "element dymicForm"
};
const _hoisted_5$4 = {
  key: 1,
  class: "element dymicForm"
};
const _hoisted_6$3 = { class: "element" };
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
  __name: "DeviceAdd",
  emits: ["closeDeviceDialog"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    onMounted(async () => {
      options.value = [];
      getManagers();
    });
    const formModel = reactive({
      deviceName: "",
      deviceValue: ""
    });
    const options = ref([]);
    const treeData = ref([]);
    const getManagers = async () => {
      const testResult = await sendCommand({}, { commandName: "GetManagers" });
      const { data } = testResult;
      if (data && data.length) {
        options.value = data.map((item) => ({
          value: item,
          label: item
        }));
        if (options.value.length) {
          formModel.deviceValue = options.value[0].value;
          getConnectFormByManagerName();
        }
      }
    };
    const getConnectFormByManagerName = async () => {
      treeData.value = [];
      const testResult = await sendCommand({ managerName: formModel.deviceValue }, { commandName: "GetCreateFormByManagerName" });
      const { data } = testResult;
      if (data && data.length) {
        treeData.value = data;
      }
      console.log("testResult", JSON.stringify(testResult));
    };
    const createDevice = async () => {
      if (!formModel.deviceName) {
        ElMessage.error("设备名称不能为空");
        return;
      }
      console.log("treeData", treeData);
      const testResult = await sendCommand(
        {
          managerName: formModel.deviceValue,
          deviceName: formModel.deviceName,
          createParams: JSON.stringify(treeData.value)
        },
        { commandName: "CreateDevice" }
      );
      const { data } = testResult;
      if (data) {
        ElMessage.success("设备添加成功");
        emit("closeDeviceDialog");
      } else {
        ElMessage.error("设备添加失败，请检查参数");
      }
    };
    const change = () => {
      getConnectFormByManagerName();
    };
    return (_ctx, _cache) => {
      const _component_el_input = resolveComponent("el-input");
      const _component_el_option = resolveComponent("el-option");
      const _component_el_select = resolveComponent("el-select");
      const _component_el_button = resolveComponent("el-button");
      return openBlock(), createElementBlock("div", _hoisted_1$6, [
        createElementVNode("div", _hoisted_2$5, [
          _cache[2] || (_cache[2] = createElementVNode("div", { class: "left" }, "设备名称", -1)),
          createVNode(_component_el_input, {
            modelValue: formModel.deviceName,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formModel.deviceName = $event),
            modelModifiers: { trim: true },
            class: "right"
          }, null, 8, ["modelValue"])
        ]),
        createElementVNode("div", _hoisted_3$4, [
          _cache[3] || (_cache[3] = createElementVNode("div", { class: "left" }, " 控制接口 ", -1)),
          createVNode(_component_el_select, {
            modelValue: formModel.deviceValue,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formModel.deviceValue = $event),
            class: "right",
            onChange: change
          }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(Fragment, null, renderList(options.value, (item) => {
                return openBlock(), createBlock(_component_el_option, {
                  key: item.value,
                  label: item.label,
                  value: item.value
                }, null, 8, ["label", "value"]);
              }), 128))
            ]),
            _: 1
          }, 8, ["modelValue"])
        ]),
        treeData.value && treeData.value.length ? (openBlock(), createElementBlock("div", _hoisted_4$4, [
          _cache[4] || (_cache[4] = createElementVNode("div", { class: "left" }, " 连接参数 ", -1)),
          createVNode(unref(index), {
            ref: "nodeTree",
            class: "right",
            data: treeData.value
          }, null, 8, ["data"])
        ])) : (openBlock(), createElementBlock("div", _hoisted_5$4, [..._cache[5] || (_cache[5] = [
          createElementVNode("div", { class: "empty-text" }, " 暂无连接参数 ", -1)
        ])])),
        createElementVNode("div", _hoisted_6$3, [
          createVNode(_component_el_button, {
            type: "primary",
            onClick: createDevice
          }, {
            default: withCtx(() => [..._cache[6] || (_cache[6] = [
              createTextVNode("确定", -1)
            ])]),
            _: 1
          })
        ])
      ]);
    };
  }
});
const _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const DeviceAdd = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-3b257c74"]]);
const deviceIcon = '<?xml version="1.0" ?><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title/><g data-name="Layer 2" id="Layer_2"><path d="M7.75,7.76a6,6,0,0,0,0,8.49l1.42-1.41a4,4,0,0,1,0-5.67Z"/><path d="M16.25,16.24a6,6,0,0,0,0-8.49L14.83,9.16a4,4,0,0,1,0,5.67Z"/><path d="M6.35,17.65a8,8,0,0,1,0-11.3L4.94,4.93a10,10,0,0,0,0,14.14Z"/><path d="M17.65,6.35a8,8,0,0,1,0,11.3l1.41,1.42a10,10,0,0,0,0-14.14Z"/></g></svg>';
const _hoisted_1$5 = { class: "icon" };
const _hoisted_2$4 = {
  key: 0,
  class: "task-card"
};
const _hoisted_3$3 = { class: "content" };
const _hoisted_4$3 = ["onClick"];
const _hoisted_5$3 = { class: "info" };
const _hoisted_6$2 = { class: "info-top" };
const _hoisted_7$2 = { class: "dt" };
const _hoisted_8$2 = { class: "label" };
const _hoisted_9$2 = { class: "tilEle" };
const _hoisted_10$2 = { class: "cus-icon" };
const _hoisted_11$1 = ["innerHTML"];
const _hoisted_12 = { key: 0 };
const _hoisted_13 = { class: "tool-icon" };
const _hoisted_14 = { class: "oper" };
const _hoisted_15 = { class: "menu-list" };
const _hoisted_16 = ["onClick"];
const _hoisted_17 = { class: "menu-list" };
const _hoisted_18 = ["onClick"];
const _hoisted_19 = ["onClick"];
const _hoisted_20 = { class: "info-bottom" };
const _hoisted_21 = {
  key: 0,
  class: "dl"
};
const _hoisted_22 = {
  key: 1,
  class: "dr"
};
const _hoisted_23 = {
  key: 1,
  class: "null-box"
};
const _hoisted_24 = { class: "cusDialog" };
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
  __name: "DeviceControlled",
  emits: ["clearSelfData"],
  setup(__props, { emit: __emit }) {
    const deviceViewStore = useDeviceViewStore();
    const deviceDetailDialogVisible = ref(false);
    const dialogVisible = ref(false);
    const tableData = ref([]);
    const clickDeviceName = ref("");
    const deviceInformationData = ref("");
    const emit = __emit;
    onMounted(async () => {
      getDevices();
    });
    onUpdated(() => {
      removeHoverEnter();
      addHoverEnter();
    });
    const addHoverEnter = () => {
      const iconInfo = document.querySelectorAll(".el-icon-info");
      if (!iconInfo || !iconInfo.length) return;
      iconInfo.forEach((iconItem) => {
        iconItem.addEventListener("mouseenter", handleMouseEnter);
        iconItem.addEventListener("mouseleave", handleMouseLeave);
      });
    };
    const removeHoverEnter = () => {
      const iconInfo = document.querySelectorAll(".el-icon-info");
      if (!iconInfo || !iconInfo.length) return;
      iconInfo.forEach((iconItem) => {
        iconItem.removeEventListener("mouseenter", handleMouseEnter);
        iconItem.removeEventListener("mouseleave", handleMouseLeave);
      });
    };
    const handleMouseEnter = (e) => {
      const cusDialog = document.querySelector(".cusDialog");
      if (!cusDialog) return;
      cusDialog.style.display = "block";
      const offsetX = 20;
      const offsetY = 20;
      cusDialog.style.left = `${e.clientX + offsetX}px`;
      cusDialog.style.top = `${e.clientY + offsetY}px`;
    };
    const handleMouseLeave = () => {
      const cusDialog = document.querySelector(".cusDialog");
      if (!cusDialog) return;
      cusDialog.style.display = "none";
    };
    const getDevices = async () => {
      const testResult = await sendCommand({}, { commandName: "GetLocalDevices" });
      if (!testResult || !testResult.data) {
        console.error("获取设备失败");
        return;
      }
      const { data } = testResult;
      tableData.value = [];
      if (!data || data.length === 0) {
        emit("clearSelfData");
        deviceViewStore.setAllDevices(tableData.value);
        return;
      }
      data.forEach((element) => {
        tableData.value.push(element);
      });
      deviceViewStore.setAllDevices(tableData.value);
      nextTick(() => {
        const firstEle = document.querySelector(".firstEle");
        firstEle == null ? void 0 : firstEle.click();
      });
    };
    const deleteDevice = (element) => {
      console.log("删除设备元素", element.id);
      ElMessageBox.confirm("确定要删除设备吗", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        customClass: "myClass"
      }).then(async () => {
        await sendCommand({ deviceId: element.id }, { commandName: "RemoveDevice" });
        await getDevices();
        deviceViewStore.removeClickedDevice(element);
      }).catch(() => {
        console.log(111);
      });
    };
    const currentIndex = ref(-1);
    const sendDeviceName = (item, index2) => {
      item.deviceIndex = index2 + 1;
      clickDeviceName.value = `${item.Version}-${item.Name}`;
      deviceViewStore.setCurrentDevice(item);
      deviceViewStore.setClickedDevice(item);
    };
    watch(
      () => deviceViewStore.currentDevice,
      (val) => {
        if (val && val.id) {
          const index2 = tableData.value.findIndex((item) => item.id === val.id);
          if (index2 !== -1) {
            currentIndex.value = index2;
          } else {
            currentIndex.value = -1;
          }
        } else {
          currentIndex.value = -1;
        }
      }
    );
    watch(
      () => deviceViewStore.closedDevice,
      async () => {
        await getDevices();
      }
    );
    watch(
      () => deviceViewStore.currentDeviceConnStatus,
      () => {
        const findEle = tableData.value.find((x) => x.id === deviceViewStore.currentDeviceConnStatus.deviceId);
        if (!findEle) return;
        console.log("状态监控方法执行", deviceViewStore.currentDeviceConnStatus);
        findEle.connectState = deviceViewStore.currentDeviceConnStatus.connectStatus;
      }
    );
    onBeforeUnmount(() => {
      console.log("组件销毁事件");
    });
    const addDevice = () => {
      dialogVisible.value = true;
    };
    const closeDeviceDialog = async () => {
      dialogVisible.value = false;
      await getDevices();
    };
    const openOrClose = async (element) => {
      let methodName = deviceViewStore.openCloseMethodName[0];
      if (element.connectState === "Connected") {
        methodName = deviceViewStore.openCloseMethodName[1];
      }
      console.log("methodName", methodName);
      const deviceId = element.id;
      const loading = ElLoading.service({
        lock: true,
        text: "处理中，请稍后...",
        background: "rgba(0, 0, 0, 0.7)"
      });
      await sendCommand(
        {
          deviceId
        },
        {
          commandName: methodName
        }
      ).catch((error) => {
        console.log("错误", error);
        loading.close();
      });
      loading.close();
      await getDevices();
    };
    const copyContent = async (content) => {
      try {
        await navigator.clipboard.writeText(content);
        ElMessage.success("复制成功！");
      } catch (err) {
        ElMessage.error("复制失败，请检查权限或手动复制");
        console.error("复制失败:", err);
      }
    };
    const modifyName = (element) => {
      var _a;
      element.isEdit = true;
      element.newDeviceName = element.name;
      (_a = document.activeElement) == null ? void 0 : _a.blur();
      nextTick(() => {
        var inputTxt = document.querySelector(".el-input__inner");
        inputTxt == null ? void 0 : inputTxt.focus();
      });
    };
    const saveDeviceName = async (element, index2) => {
      element.isEdit = false;
      await sendCommand(
        {
          deviceId: element.id,
          newName: element.name
        },
        {
          commandName: "UpdateDeviceName"
        }
      );
      ElMessage.success("设备重命名成功！");
      await getDevices();
      nextTick(() => {
        currentIndex.value = index2;
        const clickCardEle = document.querySelector(".clickCard");
        clickCardEle == null ? void 0 : clickCardEle.click();
      });
    };
    return (_ctx, _cache) => {
      const _component_el_icon = resolveComponent("el-icon");
      const _component_el_tooltip = resolveComponent("el-tooltip");
      const _component_el_header = resolveComponent("el-header");
      const _component_el_popover = resolveComponent("el-popover");
      const _component_el_scrollbar = resolveComponent("el-scrollbar");
      const _component_el_dialog = resolveComponent("el-dialog");
      const _component_DeviceDetail = resolveComponent("DeviceDetail");
      const _component_el_container = resolveComponent("el-container");
      return openBlock(), createBlock(_component_el_container, { class: "root" }, {
        default: withCtx(() => [
          createVNode(_component_el_header, null, {
            default: withCtx(() => [
              _cache[1] || (_cache[1] = createElementVNode("span", null, "被控设备", -1)),
              createElementVNode("span", _hoisted_1$5, [
                createVNode(_component_el_tooltip, {
                  content: "扫描设备",
                  placement: "top-start"
                }, {
                  default: withCtx(() => [
                    createVNode(_component_el_icon, null, {
                      default: withCtx(() => [
                        createVNode(unref(Search))
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                }),
                createVNode(_component_el_tooltip, {
                  content: "添加设备",
                  placement: "top-start"
                }, {
                  default: withCtx(() => [
                    createVNode(_component_el_icon, { onClick: addDevice }, {
                      default: withCtx(() => [
                        createVNode(unref(CirclePlus))
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                })
              ])
            ]),
            _: 1
          }),
          tableData.value && tableData.value.length ? (openBlock(), createElementBlock("div", _hoisted_2$4, [
            createVNode(_component_el_scrollbar, null, {
              default: withCtx(() => [
                createElementVNode("div", _hoisted_3$3, [
                  (openBlock(true), createElementBlock(Fragment, null, renderList(tableData.value, (element, i) => {
                    return openBlock(), createElementBlock("div", {
                      key: i,
                      class: normalizeClass(["content-list", { clickCard: currentIndex.value === i, firstEle: i === 0, lastEle: i === tableData.value.length - 1 }]),
                      onClick: ($event) => sendDeviceName(element, i)
                    }, [
                      createElementVNode("div", _hoisted_5$3, [
                        createElementVNode("div", _hoisted_6$2, [
                          createElementVNode("div", _hoisted_7$2, [
                            createElementVNode("div", _hoisted_8$2, [
                              createElementVNode("span", _hoisted_9$2, [
                                createElementVNode("span", _hoisted_10$2, [
                                  createElementVNode("span", {
                                    class: "force-svg-16",
                                    innerHTML: unref(deviceIcon)
                                  }, null, 8, _hoisted_11$1)
                                ]),
                                !element.isEdit ? (openBlock(), createElementBlock("span", _hoisted_12, toDisplayString(`${element.name}`), 1)) : (openBlock(), createBlock(unref(ElInput), {
                                  key: 1,
                                  modelValue: element.name,
                                  "onUpdate:modelValue": ($event) => element.name = $event,
                                  onKeyup: withKeys(($event) => saveDeviceName(element, i), ["enter"]),
                                  onBlur: ($event) => saveDeviceName(element, i)
                                }, null, 8, ["modelValue", "onUpdate:modelValue", "onKeyup", "onBlur"]))
                              ]),
                              createElementVNode("div", _hoisted_13, [
                                createElementVNode("div", _hoisted_14, [
                                  createVNode(_component_el_icon, {
                                    class: normalizeClass({ "open-status": element.connectState === "Connected" }),
                                    onClick: withModifiers(($event) => openOrClose(element), ["stop"])
                                  }, {
                                    default: withCtx(() => [
                                      createVNode(unref(SwitchButton))
                                    ]),
                                    _: 2
                                  }, 1032, ["class", "onClick"]),
                                  createVNode(_component_el_popover, {
                                    placement: "right",
                                    width: "auto",
                                    "popper-class": "my-information-popover"
                                  }, {
                                    reference: withCtx(() => [
                                      createVNode(_component_el_icon, null, {
                                        default: withCtx(() => [
                                          createVNode(unref(Warning))
                                        ]),
                                        _: 1
                                      })
                                    ]),
                                    default: withCtx(() => [
                                      createElementVNode("div", _hoisted_15, [
                                        (openBlock(true), createElementBlock(Fragment, null, renderList(element.information, (item, index2) => {
                                          return openBlock(), createElementBlock("div", {
                                            class: "menu-item",
                                            key: index2
                                          }, [
                                            createElementVNode("div", null, toDisplayString(item.name) + "：", 1),
                                            createElementVNode("div", {
                                              class: "value",
                                              onClick: ($event) => copyContent(item.value)
                                            }, toDisplayString(item.value), 9, _hoisted_16)
                                          ]);
                                        }), 128))
                                      ])
                                    ]),
                                    _: 2
                                  }, 1024),
                                  createVNode(_component_el_popover, {
                                    placement: "right",
                                    width: "20px",
                                    "popper-class": "my-popover",
                                    trigger: "click"
                                  }, {
                                    reference: withCtx(() => [
                                      createVNode(_component_el_icon, null, {
                                        default: withCtx(() => [
                                          createVNode(unref(MoreFilled))
                                        ]),
                                        _: 1
                                      })
                                    ]),
                                    default: withCtx(() => [
                                      createElementVNode("div", _hoisted_17, [
                                        createElementVNode("div", {
                                          class: "menu-item",
                                          onClick: withModifiers(($event) => modifyName(element), ["stop"])
                                        }, [
                                          createVNode(_component_el_icon, null, {
                                            default: withCtx(() => [
                                              createVNode(unref(Edit))
                                            ]),
                                            _: 1
                                          }),
                                          _cache[2] || (_cache[2] = createElementVNode("div", null, "重命名设备", -1))
                                        ], 8, _hoisted_18),
                                        createElementVNode("div", {
                                          class: "menu-item",
                                          onClick: withModifiers(($event) => deleteDevice(element), ["stop"])
                                        }, [
                                          createVNode(_component_el_icon, null, {
                                            default: withCtx(() => [
                                              createVNode(unref(Delete))
                                            ]),
                                            _: 1
                                          }),
                                          _cache[3] || (_cache[3] = createElementVNode("div", null, "删除设备", -1))
                                        ], 8, _hoisted_19)
                                      ])
                                    ]),
                                    _: 2
                                  }, 1024)
                                ])
                              ])
                            ])
                          ])
                        ]),
                        createElementVNode("div", _hoisted_20, [
                          (openBlock(true), createElementBlock(Fragment, null, renderList(element.information, (item, index2) => {
                            return openBlock(), createElementBlock("div", {
                              key: item.id,
                              class: "dt"
                            }, [
                              index2 <= 3 ? (openBlock(), createElementBlock("div", _hoisted_21, toDisplayString(item.name) + "：", 1)) : createCommentVNode("", true),
                              index2 <= 3 ? (openBlock(), createElementBlock("div", _hoisted_22, toDisplayString(item.value), 1)) : createCommentVNode("", true)
                            ]);
                          }), 128))
                        ])
                      ])
                    ], 10, _hoisted_4$3);
                  }), 128))
                ])
              ]),
              _: 1
            })
          ])) : (openBlock(), createElementBlock("div", _hoisted_23, "暂无数据")),
          createVNode(_component_el_dialog, {
            title: "设备添加",
            modelValue: dialogVisible.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dialogVisible.value = $event),
            width: "35%",
            fullscreen: false
          }, {
            default: withCtx(() => [
              dialogVisible.value ? (openBlock(), createBlock(DeviceAdd, {
                key: 0,
                onCloseDeviceDialog: closeDeviceDialog
              })) : createCommentVNode("", true)
            ]),
            _: 1
          }, 8, ["modelValue"]),
          createElementVNode("div", _hoisted_24, [
            deviceDetailDialogVisible.value ? (openBlock(), createBlock(_component_DeviceDetail, {
              key: 0,
              deviceInformationData: deviceInformationData.value
            }, null, 8, ["deviceInformationData"])) : createCommentVNode("", true)
          ])
        ]),
        _: 1
      });
    };
  }
});
const DeviceControlled = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-16025a48"]]);
const _hoisted_1$4 = {
  ref: "splitChild",
  class: "splitChild"
};
const _hoisted_2$3 = {
  ref: "deviceControlled",
  class: "deviceControlled"
};
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  ...{
    name: "DeviceList"
  },
  __name: "DeviceList",
  props: {
    allMethodDicSer: {
      type: String,
      default: ""
    }
  },
  setup(__props) {
    const props = __props;
    const midSerData = ref("");
    onMounted(() => {
      midSerData.value = props.allMethodDicSer;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$4, [
        createElementVNode("div", _hoisted_2$3, [
          createVNode(DeviceControlled, { allMethodDicSer: midSerData.value }, null, 8, ["allMethodDicSer"])
        ], 512)
      ], 512);
    };
  }
});
const DeviceList = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-ecba7d16"]]);
const _hoisted_1$3 = {
  key: 1,
  class: "null-box"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...{
    name: "DirectiveConfig"
  },
  __name: "DirectiveConfig",
  props: {
    treeNodeId: {
      type: String,
      default: ""
    }
  },
  setup(__props, { expose: __expose }) {
    const deviceViewStore = useDeviceViewStore();
    const treeData = ref([]);
    const props = __props;
    onMounted(async () => {
      getParamsByCommandId();
    });
    watch(
      () => props.treeNodeId,
      () => {
        treeData.value = [];
        getParamsByCommandId();
      }
    );
    watch(
      () => deviceViewStore.clickedDevice.length,
      (val) => {
        if (val === 0) {
          clearSelfData();
        }
      }
    );
    const getParamsByCommandId = async () => {
      var _a;
      if (!((_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id)) return;
      const testResult = await sendCommand({ deviceId: deviceViewStore.currentDevice.id, commandId: props.treeNodeId }, { commandName: "GetParamsByCommandId" });
      treeData.value = testResult.data;
    };
    const saveConfig = async () => {
      var _a;
      await sendCommand(
        {
          deviceId: (_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id,
          commandId: props.treeNodeId,
          commandParam: JSON.stringify(treeData.value)
        },
        {
          commandName: "SendCommandParam"
        }
      );
    };
    const clearSelfData = () => {
      treeData.value = [];
    };
    __expose({
      getParamsByCommandId,
      saveConfig
    });
    return (_ctx, _cache) => {
      const _component_el_header = resolveComponent("el-header");
      const _component_el_main = resolveComponent("el-main");
      const _component_el_container = resolveComponent("el-container");
      return openBlock(), createBlock(_component_el_container, { class: "root" }, {
        default: withCtx(() => [
          createVNode(_component_el_header, null, {
            default: withCtx(() => [..._cache[0] || (_cache[0] = [
              createElementVNode("div", null, "指令参数", -1)
            ])]),
            _: 1
          }),
          createVNode(_component_el_main, null, {
            default: withCtx(() => [
              treeData.value && treeData.value.length ? (openBlock(), createBlock(unref(index), {
                key: 0,
                ref: "nodeTree",
                data: treeData.value
              }, null, 8, ["data"])) : (openBlock(), createElementBlock("div", _hoisted_1$3, "暂无数据"))
            ]),
            _: 1
          })
        ]),
        _: 1
      });
    };
  }
});
const DirectiveConfig = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-1aca8cd9"]]);
const cmdIcon = '<svg version="1.1" width="36" height="36"  viewBox="0 0 36 36" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\r\n    <path d="M30,13.5a7.49,7.49,0,0,1-6.78-4.3H4V7H22.57a7.52,7.52,0,0,1-.07-1,7.52,7.52,0,0,1,.07-1H4A2,2,0,0,0,2,7V29a2,2,0,0,0,2,2H32a2,2,0,0,0,2-2V12.34A7.46,7.46,0,0,1,30,13.5ZM16.8,19.83l-10,4.59V21.78l6.51-3-6.51-3V13.17l10,4.59Zm6.6,5.57H17V23h6.4Z" class="clr-i-solid--badged clr-i-solid-path-1--badged"></path><circle cx="30" cy="6" r="5" class="clr-i-solid--badged clr-i-solid-path-2--badged clr-i-badge"></circle>\r\n    <rect x="0" y="0" width="36" height="36" fill-opacity="0"/>\r\n</svg>';
const arrowRight = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M0 0l20 10L0 20V0zm0 8v4l10-2L0 8z"/></svg>';
const _hoisted_1$2 = { class: "root" };
const _hoisted_2$2 = { class: "seacher" };
const _hoisted_3$2 = ["onMouseenter"];
const _hoisted_4$2 = { class: "part_left" };
const _hoisted_5$2 = { class: "cus-icon2" };
const _hoisted_6$1 = ["innerHTML"];
const _hoisted_7$1 = { key: 0 };
const _hoisted_8$1 = { key: 1 };
const _hoisted_9$1 = { class: "cus-icon" };
const _hoisted_10$1 = ["innerHTML", "onClick"];
const _hoisted_11 = {
  key: 1,
  class: "null-box"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...{
    name: "DirectiveList"
  },
  __name: "DirectiveList",
  emits: ["getDirectiveConfig", "exeCmd"],
  setup(__props, { emit: __emit }) {
    const deviceViewStore = useDeviceViewStore();
    const treeData = ref([]);
    const defaultProps = ref({
      children: "children",
      // label: "Description",
      label: "name"
    });
    const tree = ref();
    const cmdSearchTxt = ref("");
    const isAlreadyClick = ref(false);
    const tempTreeNodeId = ref("");
    const emit = __emit;
    watch(
      () => {
        var _a;
        return (_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id;
      },
      () => {
        getCommandsByDeviceName();
      }
    );
    watch(
      () => deviceViewStore.clickedDevice.length,
      (val) => {
        if (val === 0) {
          clearSelfData();
        }
      }
    );
    const handleNodeClick = (data) => {
      tempTreeNodeId.value = data.id;
      emit("getDirectiveConfig", data.id);
      if (isAlreadyClick.value) return;
      isAlreadyClick.value = true;
    };
    const treeNodeId = ref("");
    onMounted(async () => {
      getCommandsByDeviceName();
    });
    const getCommandsByDeviceName = async () => {
      var _a, _b;
      if (!((_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id)) return;
      const testResult = await sendCommand({ deviceId: deviceViewStore.currentDevice.id }, { commandName: "GetCommandByDeviceName" });
      const { data } = testResult;
      if (data && data.length) {
        treeData.value = data;
        deviceViewStore.storeCommandList(data);
        for (let i = 0; i < 2; i++) {
          const methodName = (_b = data[i]) == null ? void 0 : _b.methodName;
          if (methodName) {
            deviceViewStore.setOpenCloseMethodName(methodName);
          }
        }
        nextTick(() => {
          tree.value.setCurrentKey(treeData.value[0].id);
          const node = tree.value.getNode(treeData.value[0].id);
          if (node) {
            handleNodeClick(node.data);
          }
        });
      }
    };
    const haldleMouseEnter = (data) => {
      treeNodeId.value = data.$treeNodeId;
    };
    const handleMouseLeave = () => {
      treeNodeId.value = "";
    };
    const exeDirective = (data) => {
      if (tempTreeNodeId.value !== data.id) {
        emit("getDirectiveConfig", data.id);
      } else {
        emit("getDirectiveConfig", data.id);
        emit("exeCmd");
      }
    };
    watch(cmdSearchTxt, (val) => {
      tree.value.filter(val);
    });
    const filterNode = (value, data) => {
      if (!value) return true;
      return data.name.includes(value.trim());
    };
    const clearSelfData = () => {
      treeData.value = [];
    };
    return (_ctx, _cache) => {
      const _component_el_header = resolveComponent("el-header");
      const _component_el_input = resolveComponent("el-input");
      const _component_el_tooltip = resolveComponent("el-tooltip");
      const _component_el_tree = resolveComponent("el-tree");
      const _component_el_scrollbar = resolveComponent("el-scrollbar");
      const _component_el_main = resolveComponent("el-main");
      return openBlock(), createElementBlock("div", _hoisted_1$2, [
        createVNode(_component_el_header, null, {
          default: withCtx(() => [..._cache[2] || (_cache[2] = [
            createTextVNode("指令列表", -1)
          ])]),
          _: 1
        }),
        createVNode(_component_el_main, null, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_2$2, [
              createVNode(_component_el_input, {
                modelValue: cmdSearchTxt.value,
                "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => cmdSearchTxt.value = $event),
                placeholder: "请输入指令信息，支持模糊查询",
                "suffix-icon": unref(Search),
                clearable: ""
              }, null, 8, ["modelValue", "suffix-icon"])
            ]),
            treeData.value && treeData.value.length ? (openBlock(), createBlock(_component_el_scrollbar, { key: 0 }, {
              default: withCtx(() => [
                createVNode(_component_el_tree, {
                  ref_key: "tree",
                  ref: tree,
                  data: treeData.value,
                  props: defaultProps.value,
                  "node-key": "id",
                  "highlight-current": true,
                  "default-expand-all": true,
                  "expand-on-click-node": false,
                  "filter-node-method": filterNode,
                  onNodeClick: handleNodeClick
                }, {
                  default: withCtx(({ node, data }) => [
                    createElementVNode("span", {
                      class: "custom-tree-node",
                      onMouseenter: ($event) => haldleMouseEnter(data),
                      onMouseleave: _cache[1] || (_cache[1] = ($event) => handleMouseLeave())
                    }, [
                      createElementVNode("span", _hoisted_4$2, [
                        createElementVNode("span", _hoisted_5$2, [
                          createElementVNode("span", { innerHTML: unref(cmdIcon) }, null, 8, _hoisted_6$1)
                        ]),
                        data.description ? (openBlock(), createElementBlock("span", _hoisted_7$1, [
                          createVNode(_component_el_tooltip, {
                            placement: "right",
                            content: data.description
                          }, {
                            default: withCtx(() => [
                              createElementVNode("span", null, toDisplayString(node.label), 1)
                            ]),
                            _: 2
                          }, 1032, ["content"])
                        ])) : (openBlock(), createElementBlock("span", _hoisted_8$1, toDisplayString(node.label), 1))
                      ]),
                      createElementVNode("span", _hoisted_9$1, [
                        createVNode(_component_el_tooltip, {
                          placement: "right",
                          content: "执行指令"
                        }, {
                          default: withCtx(() => [
                            createElementVNode("span", {
                              innerHTML: unref(arrowRight),
                              onClick: withModifiers(($event) => exeDirective(data), ["stop"])
                            }, null, 8, _hoisted_10$1)
                          ]),
                          _: 2
                        }, 1024)
                      ])
                    ], 40, _hoisted_3$2)
                  ]),
                  _: 1
                }, 8, ["data", "props"])
              ]),
              _: 1
            })) : (openBlock(), createElementBlock("div", _hoisted_11, "暂无数据"))
          ]),
          _: 1
        })
      ]);
    };
  }
});
const DirectiveList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-6f5c72be"]]);
class DataLoader {
  constructor(pageSize, totalDataCount, scrollContainer, nextFlag, callbackFn) {
    __publicField(this, "scrollContainer");
    __publicField(this, "nextFlag");
    __publicField(this, "paginatedData");
    __publicField(this, "onLoadCallback");
    // 使用类属性箭头函数绑定 this
    __publicField(this, "handleScroll", _.debounce(() => {
      if (!this.nextFlag) {
        this.loadPreviousPageData();
      } else {
        this.loadNextPageData();
      }
    }, 300));
    this.scrollContainer = scrollContainer;
    this.nextFlag = nextFlag;
    const totalPage = Math.ceil(totalDataCount / pageSize);
    const modeVal = totalDataCount % pageSize;
    const lastStartPage = modeVal === 0 ? 0 : 1;
    const currentIndex = nextFlag ? 1 : totalPage - lastStartPage;
    this.scrollContainer.addEventListener("scroll", this.handleScroll);
    this.paginatedData = {
      currentIndex,
      pageSize,
      totalPage,
      totalDataCount
    };
    this.onLoadCallback = callbackFn;
  }
  destroy() {
    this.scrollContainer.removeEventListener("scroll", this.handleScroll);
  }
  updatePaginInfo(currentIndex, newTotalDataCount) {
    const totalPage = Math.ceil(newTotalDataCount / this.paginatedData.pageSize);
    this.paginatedData = {
      currentIndex,
      pageSize: this.paginatedData.pageSize,
      totalPage,
      totalDataCount: newTotalDataCount
    };
  }
  getInitData() {
    console.log("获取首页数据");
  }
  // 调整防抖时间为 300ms
  loadPreviousPageData() {
    var _a;
    const isScrollingTop = this.scrollContainer.scrollTop < 100;
    if (isScrollingTop) {
      if (this.paginatedData.currentIndex > 1) {
        this.paginatedData.currentIndex--;
        (_a = this.onLoadCallback) == null ? void 0 : _a.call(this, this.paginatedData);
        this.scrollContainer.scrollTop = 200;
      }
      console.log("加载上一页数据", this.paginatedData.currentIndex);
    }
  }
  loadNextPageData() {
    var _a;
    const scrollHeight = this.scrollContainer.scrollHeight;
    const scrollTop = this.scrollContainer.scrollTop;
    const scrollClient = this.scrollContainer.clientHeight;
    const isScrollingBottom = scrollHeight - scrollTop - scrollClient < 100;
    if (isScrollingBottom) {
      this.paginatedData.currentIndex++;
      if (this.paginatedData.currentIndex <= this.paginatedData.totalPage) {
        (_a = this.onLoadCallback) == null ? void 0 : _a.call(this, this.paginatedData);
        this.scrollContainer.scrollTop = scrollHeight;
      }
    }
  }
  setScroll() {
    if (this.nextFlag) {
      const scrollHeight = this.scrollContainer.scrollHeight;
      this.scrollContainer.scrollTop = scrollHeight - 300 < 0 ? 0 : scrollHeight - 300;
    } else {
      const scrollHeight = this.scrollContainer.scrollHeight;
      console.log("this.paginatedData.currentIndex", this.paginatedData.currentIndex);
      this.scrollContainer.scrollTop = scrollHeight < 200 ? 0 : 200;
    }
  }
}
const _sfc_main$2 = defineComponent({
  name: "DataContainer",
  props: {
    dataList: {
      type: String,
      default: ""
    },
    initProps: {
      type: String,
      default: ""
    },
    dataSingle: {
      type: String,
      default: ""
    }
  },
  setup(props, { emit }) {
    const dataArray = ref([]);
    const isHtml = ref(false);
    const isStayTop = ref(true);
    const initPropsObj = ref(null);
    const showErMsg = ref(false);
    const scrollbar = ref(null);
    let dataLoader = null;
    const dataSingleChange = (val) => {
      const dataSingle = JSON.parse(val);
      dataArray.value.push(dataSingle);
      if (dataArray.value.length > 100) {
        dataArray.value = dataArray.value.slice(-100);
      }
      nextTick(() => {
        if (scrollbar.value) {
          scrollbar.value.wrapRef.scrollTop = scrollbar.value.wrapRef.scrollHeight;
        }
      });
    };
    const initPropsChange = (val) => {
      initPropsObj.value = JSON.parse(val);
      isStayTop.value = initPropsObj.value.isBottomScroll;
      isHtml.value = initPropsObj.value.isHtml;
      if (dataLoader === null) {
        dataLoader = new DataLoader(
          initPropsObj.value.paginatedData.pageSize,
          initPropsObj.value.paginatedData.totalDataCount,
          scrollbar.value.wrapRef,
          initPropsObj.value.isBottomScroll,
          onLoadCallback
        );
      } else {
        dataLoader.updatePaginInfo(initPropsObj.value.paginatedData.currentIndex, initPropsObj.value.paginatedData.totalDataCount);
      }
    };
    const dataListChange = (val) => {
      const dataList = JSON.parse(val);
      dataArray.value = [...dataList];
    };
    const onLoadCallback = async (data) => {
      const paginatedData = {
        currentIndex: data.currentIndex,
        pageSize: data.pageSize,
        totalDataCount: data.totalDataCount
      };
      emit("callback", paginatedData);
    };
    const searchInfo = (inputTxt) => {
      showErMsg.value = false;
      if (!isHtml.value) return;
      dataArray.value.forEach((item) => {
        item.Content = item.Content.replace(/<span class="highlight">(.*?)<\/span>/g, (_match, p1) => p1);
      });
      if (!inputTxt.trim()) return;
      const regex = new RegExp(`(${inputTxt.trim()})`, "gi");
      dataArray.value.forEach((item) => {
        item.Content = item.Content.replace(regex, '<span class="highlight">$1</span>');
      });
      nextTick(() => {
        const firstHighlight = document.querySelector(".highlight");
        if (firstHighlight) {
          showErMsg.value = false;
          if (scrollbar.value) {
            scrollbar.value.wrapRef.scrollTop = firstHighlight.offsetTop;
          }
        } else {
          showErMsg.value = true;
        }
      });
    };
    onMounted(() => {
      const initProps = JSON.parse(props.initProps);
      if (initProps && initProps.isHtml) {
        isHtml.value = initProps.isHtml;
      }
    });
    onBeforeUnmount(() => {
      dataLoader == null ? void 0 : dataLoader.destroy();
      dataLoader = null;
    });
    watch(() => props.dataSingle, dataSingleChange);
    watch(() => props.initProps, initPropsChange);
    watch(() => props.dataList, dataListChange);
    return {
      dataArray,
      isHtml,
      isStayTop,
      showErMsg,
      scrollbar,
      searchInfo
    };
  }
});
const _hoisted_1$1 = { class: "dataContainer" };
const _hoisted_2$1 = {
  key: 0,
  class: "errMsg"
};
const _hoisted_3$1 = { key: 0 };
const _hoisted_4$1 = ["innerHTML"];
const _hoisted_5$1 = { key: 1 };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
  return openBlock(), createElementBlock("div", _hoisted_1$1, [
    _ctx.showErMsg ? (openBlock(), createElementBlock("span", _hoisted_2$1, "未检索到指定内容")) : createCommentVNode("", true),
    createVNode(_component_el_scrollbar, { ref: "scrollbar" }, {
      default: withCtx(() => [
        _ctx.isHtml ? (openBlock(), createElementBlock("ul", _hoisted_3$1, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.dataArray, (item) => {
            return openBlock(), createElementBlock("li", {
              key: item.Id,
              class: "li"
            }, [
              createElementVNode("pre", {
                innerHTML: item.Content
              }, null, 8, _hoisted_4$1)
            ]);
          }), 128))
        ])) : (openBlock(), createElementBlock("ul", _hoisted_5$1, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.dataArray, (item) => {
            return openBlock(), createElementBlock("li", {
              key: item.Id,
              class: "li"
            }, toDisplayString(item.Content), 1);
          }), 128))
        ]))
      ]),
      _: 1
    }, 512)
  ]);
}
const DataContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render], ["__scopeId", "data-v-c422f1de"]]);
const _hoisted_1 = { class: "cmd-log" };
const _hoisted_2 = { class: "top-view" };
const _hoisted_3 = { class: "tit" };
const _hoisted_4 = ["onClick"];
const _hoisted_5 = ["id"];
const _hoisted_6 = ["for"];
const _hoisted_7 = { class: "toolbar" };
const _hoisted_8 = { class: "body-view" };
const _hoisted_9 = { class: "seacher" };
const _hoisted_10 = {
  key: 0,
  class: "errMsg"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...{
    name: "CmdEnforcement"
  },
  __name: "CmdEnforcement",
  props: {
    manualTestLog: {
      type: String,
      default: ""
    }
  },
  setup(__props) {
    const deviceViewStore = useDeviceViewStore();
    const props = __props;
    const dataContainer = ref(null);
    const highlightedIndex = ref(0);
    const dataContainerStruct = ref([]);
    const dataContainerStructSingle = ref({
      Id: "",
      Content: ""
    });
    const searchInfo = ref("");
    const showErMsg = ref(false);
    const effect = ref("light");
    const pageObj = reactive({
      currentIndex: 1,
      pageSize: 100,
      totalDataCount: 0
    });
    const dataContainerInit = ref({
      paginatedData: pageObj,
      isBottomScroll: false,
      isHtml: true
    });
    const getAllCount = async () => {
      var _a, _b;
      if (!((_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id)) return;
      const testResult = await sendCommand(
        { deviceId: (_b = deviceViewStore.currentDevice) == null ? void 0 : _b.id },
        { commandName: "GetManualTestLogsCount" }
      );
      const { data } = testResult;
      pageObj.totalDataCount = data;
    };
    watch(
      () => {
        var _a;
        return (_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id;
      },
      async (val) => {
        if (!val) return;
        dataContainerStruct.value = [];
        highlightedIndex.value = deviceViewStore.clickedDevice.findIndex((childItem) => childItem.id === val);
        console.log("获取总条数");
        await getAllCount();
        await getHistoryLogByPage();
        if (dataContainerStruct.value.length < pageObj.pageSize) {
          pageObj.currentIndex--;
          await getHistoryLogByPage();
        }
      },
      {
        immediate: true
      }
    );
    watch(
      () => deviceViewStore.clickedDevice.length,
      (val) => {
        if (val === 0) {
          dataContainerStruct.value = [];
          highlightedIndex.value = 0;
        }
      }
    );
    watch(
      () => props.manualTestLog,
      async () => {
        const obj = JSON.parse(props.manualTestLog);
        const opeContent = obj.content.replace(/\r\n/g, "<br>");
        const format = "HH:mm:ss.SSS";
        const judge = moment(obj.dateTime, format, true).isValid();
        if (!judge) {
          obj.dateTime = moment(obj.dateTime).format("HH:mm:ss.SSS");
        }
        dataContainerStructSingle.value = {
          Id: v4(),
          Content: `${obj.dateTime} ${obj.actionType} ${opeContent}`
        };
        pageObj.totalDataCount++;
      }
    );
    watch(
      () => highlightedIndex.value,
      () => {
        dataContainerStruct.value = [];
      }
    );
    watch(
      () => pageObj.totalDataCount,
      () => {
        const totalPage = Math.ceil(pageObj.totalDataCount / pageObj.pageSize);
        pageObj.currentIndex = totalPage;
      }
    );
    const highlightItem = (index2) => {
      highlightedIndex.value = index2;
      if (deviceViewStore.clickedDevice.length > index2) {
        deviceViewStore.setCurrentDevice(deviceViewStore.clickedDevice[index2]);
      }
    };
    const closeCurrentTab = (ele) => {
      deviceViewStore.removeClickedDevice(ele);
      if (deviceViewStore.allDevices.length !== 0) {
        deviceViewStore.setCurrentDevice(deviceViewStore.allDevices[0]);
      }
      dataContainerStruct.value = [];
      deviceViewStore.setClosedDevice(ele);
    };
    const clearLog = async () => {
      var _a;
      dataContainerStruct.value = [];
      await sendCommand(
        { deviceId: (_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id },
        { commandName: "ClearLogs" }
      );
      ElMessage.success("日志清除成功");
      console.log("clearLog");
    };
    const downloadLogFile = async () => {
      var _a, _b, _c;
      const blob = await downloadFileCommand(
        { deviceId: (_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id },
        { commandName: "GetLogFile" },
        { responseType: "blob" }
      );
      console.log("获取日志文件", blob);
      const link = document.createElement("a");
      const url = URL.createObjectURL(blob);
      link.href = url;
      link.download = `${(_b = deviceViewStore.currentDevice) == null ? void 0 : _b.name}-${(_c = deviceViewStore.currentDevice) == null ? void 0 : _c.version}.log`;
      link.click();
      URL.revokeObjectURL(url);
    };
    const searchCmdInfo = () => {
      var _a;
      (_a = dataContainer.value) == null ? void 0 : _a.searchInfo(searchInfo.value);
    };
    const getHistoryLogByPage = async () => {
      var _a, _b;
      const testResult = await sendCommand(
        {
          deviceId: (_a = deviceViewStore.currentDevice) == null ? void 0 : _a.id,
          pageIndex: pageObj.currentIndex,
          pageSize: pageObj.pageSize
        },
        { commandName: "GetManualTestLogsByPage" }
      );
      const { data } = testResult;
      if (data && ((_b = data.list) == null ? void 0 : _b.length)) {
        const tempLogList = data.list.map((log) => ({
          Id: v4(),
          Content: log.replace(/\r\n/g, "<br>")
        }));
        dataContainerStruct.value = [...tempLogList, ...dataContainerStruct.value];
      }
    };
    onMounted(async () => {
      const currentTheme = localStorage.getItem("theme");
      if (currentTheme) {
        effect.value = "dark";
      }
    });
    const callback = async (data) => {
      Object.assign(pageObj, data);
      await getHistoryLogByPage();
    };
    return (_ctx, _cache) => {
      const _component_el_icon = resolveComponent("el-icon");
      const _component_el_tooltip = resolveComponent("el-tooltip");
      const _component_el_input = resolveComponent("el-input");
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createElementVNode("div", _hoisted_3, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(unref(deviceViewStore).clickedDevice, (item, index2) => {
              return openBlock(), createElementBlock("div", {
                key: index2,
                class: normalizeClass({ "deviceHighligt": highlightedIndex.value === index2 }),
                onClick: withModifiers(($event) => highlightItem(index2), ["stop"])
              }, [
                createElementVNode("input", {
                  id: String(index2),
                  type: "radio",
                  name: "tab-radio",
                  class: "tab-radio",
                  checked: ""
                }, null, 8, _hoisted_5),
                createElementVNode("label", {
                  for: String(index2),
                  class: "tab-handler"
                }, [
                  createElementVNode("span", null, toDisplayString(item.name), 1),
                  createElementVNode("span", null, [
                    createVNode(_component_el_icon, null, {
                      default: withCtx(() => [
                        createVNode(unref(Close), {
                          onClick: withModifiers(($event) => closeCurrentTab(item), ["stop"])
                        }, null, 8, ["onClick"])
                      ]),
                      _: 2
                    }, 1024)
                  ])
                ], 8, _hoisted_6)
              ], 10, _hoisted_4);
            }), 128))
          ]),
          createElementVNode("div", _hoisted_7, [
            createVNode(_component_el_tooltip, {
              placement: "top-start",
              content: "清除日志"
            }, {
              default: withCtx(() => [
                createVNode(_component_el_icon, null, {
                  default: withCtx(() => [
                    createVNode(unref(Delete), { onClick: clearLog })
                  ]),
                  _: 1
                })
              ]),
              _: 1
            }),
            createVNode(_component_el_tooltip, {
              placement: "top-start",
              content: "导出日志"
            }, {
              default: withCtx(() => [
                createVNode(_component_el_icon, null, {
                  default: withCtx(() => [
                    createVNode(unref(Download), { onClick: downloadLogFile })
                  ]),
                  _: 1
                })
              ]),
              _: 1
            })
          ])
        ]),
        createElementVNode("div", _hoisted_8, [
          createElementVNode("div", _hoisted_9, [
            createVNode(_component_el_input, {
              modelValue: searchInfo.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchInfo.value = $event),
              placeholder: "请输入关键字",
              "suffix-icon": unref(Search),
              clearable: "",
              onChange: searchCmdInfo
            }, null, 8, ["modelValue", "suffix-icon"])
          ]),
          showErMsg.value ? (openBlock(), createElementBlock("span", _hoisted_10, "未检索到指定内容")) : createCommentVNode("", true),
          createVNode(DataContainer, {
            ref_key: "dataContainer",
            ref: dataContainer,
            initProps: JSON.stringify(dataContainerInit.value),
            dataList: JSON.stringify(dataContainerStruct.value),
            dataSingle: JSON.stringify(dataContainerStructSingle.value),
            onCallback: callback
          }, null, 8, ["initProps", "dataList", "dataSingle"])
        ])
      ]);
    };
  }
});
const CMDEnforcement = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9859b36e"]]);
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "DeviceView",
    components: {}
  },
  __name: "index",
  setup(__props, { expose: __expose }) {
    const deviceView = useDeviceViewStore();
    const dataEvent = (eventData) => {
      const { dataName, data } = eventData;
      if (dataName === "log") {
        manualTestLog.value = JSON.stringify(data);
      } else if (dataName === "deviceState") {
        deviceView.setCurrentDeviceConnStatus(data);
      }
    };
    __expose({
      dataEvent
    });
    const deviceStore = useDeviceStore();
    console.log("存储后 Pinia 中的值：", deviceStore.sendDeviceCmd);
    const split = ref(null);
    const deviceList = ref(null);
    const directiveList = ref(null);
    const directiveConfig = ref(null);
    const directiveConfigChild = ref(null);
    const cmdEnforcement = ref(null);
    const cmdEnforcementChild = ref(null);
    const allMethodDicSer = ref("");
    const treeNodeId = ref("");
    const manualTestLog = ref("");
    onMounted(async () => {
      const options = [
        { el: [deviceList.value, directiveList.value, directiveConfig.value, cmdEnforcement.value], direction: "horizontal", sizes: [20, 20, 20, 40] }
      ];
      options.forEach((item) => {
        if (!item.el) return;
        Split(item.el, {
          snapOffset: 0,
          gutterSize: 3,
          sizes: item.sizes,
          direction: item.direction,
          onDragEnd: () => {
            console.log("拖动后执行");
          }
        });
      });
    });
    const getDirectiveConfig = (id) => {
      treeNodeId.value = id;
    };
    const exeCmd = () => {
      directiveConfigChild.value.saveConfig();
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        ref_key: "split",
        ref: split,
        class: "split"
      }, [
        createElementVNode("div", {
          ref_key: "deviceList",
          ref: deviceList,
          class: "deviceList"
        }, [
          createVNode(DeviceList, {
            ref: "deviceListChild",
            allMethodDicSer: allMethodDicSer.value
          }, null, 8, ["allMethodDicSer"])
        ], 512),
        createElementVNode("div", {
          ref_key: "directiveList",
          ref: directiveList,
          class: "directiveList"
        }, [
          createVNode(DirectiveList, {
            ref: "directiveListChild",
            onGetDirectiveConfig: getDirectiveConfig,
            onExeCmd: exeCmd
          }, null, 512)
        ], 512),
        createElementVNode("div", {
          ref_key: "directiveConfig",
          ref: directiveConfig,
          class: "directiveConfig"
        }, [
          createVNode(DirectiveConfig, {
            ref_key: "directiveConfigChild",
            ref: directiveConfigChild,
            treeNodeId: treeNodeId.value
          }, null, 8, ["treeNodeId"])
        ], 512),
        createElementVNode("div", {
          ref_key: "cmdEnforcement",
          ref: cmdEnforcement,
          class: "cmdEnforcement"
        }, [
          createVNode(CMDEnforcement, {
            ref_key: "cmdEnforcementChild",
            ref: cmdEnforcementChild,
            manualTestLog: manualTestLog.value
          }, null, 8, ["manualTestLog"])
        ], 512)
      ], 512);
    };
  }
});
const DeviceForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7388d0ca"]]);
const config = {
  moudleType: "DeviceForm",
  name: "设备模块",
  version: "1.0.0",
  description: "设备列表查询"
};
class DeviceModule {
  constructor(sendCmd, initialData = {}) {
    __publicField(this, "config", config);
    __publicField(this, "_eventData");
    __publicField(this, "sendCmd");
    this._eventData = ref(initialData);
    this.sendCmd = sendCmd;
  }
  sendCommand(cmd, cmdParams) {
    console.log("发送指令：", cmd, cmdParams);
    return this.sendCmd(this.config.moudleType, cmd, cmdParams);
  }
  install(app) {
    app.component("DeviceForm", DeviceForm);
    app.provide(GET_DEVICE_DATA_KEY, () => this.eventData);
    app.provide(SEND_DEVICE_CMD_KEY, (cmd, cmdParams) => {
      console.log("插件内部转发指令：", cmd, cmdParams);
      return this.sendCommand(cmd, cmdParams);
    });
  }
  get eventData() {
    return this._eventData;
  }
  dataEvent(data) {
    Object.assign(this._eventData, data);
  }
  async startup() {
    const taskStore = useDeviceStore();
    if (!taskStore.sendDeviceCmd) {
      console.log("Pinia 中未存储 sendDeviceCmd,进行存储");
      taskStore.setInjections({
        sendDeviceCmd: (cmd, cmdParams) => this.sendCommand(cmd, cmdParams)
      });
    }
    console.log("插件根组件获取到 sendDeviceCmd,初始化成功", taskStore.sendDeviceCmd);
    console.log("存储后 Pinia 中的值：", taskStore.sendDeviceCmd);
    console.log("任务模块初始化完成");
  }
}
const createDeviceModule = (sendCmd, initialData) => {
  return new DeviceModule(sendCmd, initialData);
};
export {
  DeviceForm,
  createDeviceModule
};
